<?php

namespace app\controller;

use app\BaseController;
use think\facade\Db;

class Test extends BaseController
{

    public function labels()
    {
       $label_info = Db::table('label')->select();
       $list = [
           'status'=>200,
           "data" => $label_info
       ];
       return json($list);
    }

    public function article(){
//        $page = input('class_id');
//        dump($_POST);
        $label_info = Db::table('article')->select();
        $list = [
            'status'=>200,
            "data" => $label_info
        ];
        return json($list);
    }
    
    public function updatelike(){
        $param = request()->param('class_id');
        $like_info = Db::table('article')->where('id','=',$param)->find();

        if ($like_info['like_id']){
            $label=0;
        }else{
            $label=1;
        }
        $label_info = Db::table('article')
            ->where('id','=',$param)
            ->update([
                'like_id'=>$label
            ]);
        if (!empty($label_info)){
            return json(['status'=>'success']);
        }else{
            return json(['status'=>'fail']);
        }


    }
}
